package cn.gson.springmvc.model.service;

import cn.gson.springmvc.model.dao.DeptDao;
import cn.gson.springmvc.model.mappers.DeptMapper;
import cn.gson.springmvc.model.pojos.Dept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class DeptService {
    @Autowired
    DeptMapper deptMapper;

    @Autowired
    DeptDao deptDao;

    @Transactional(value ="transactionManager_mybatis" ,rollbackFor = Exception.class)
    public List<Dept> findAll(){
        return deptMapper.findAll();
        //return (List<Dept>)deptDao.findAll();
    }

    @Transactional(value ="transactionManager" ,rollbackFor = Exception.class)
    public void addDept(Dept dept){
        deptDao.save(dept);
       // deptMapper.insertDept(dept);
    }
}
